local g = vim.g
local o = vim.o
local fn = vim.fn
local remap = vim.api.nvim_set_keymap

g.loaded_python_provider = 0
g.loaded_python3_provider = 0
g.loaded_ruby_provider = 0
g.loaded_perl_provider = 0

g.mapleader = " "
g.maplocalleader = ","

local indent = 2
o.shiftwidth = indent
o.tabstop = indent
o.number = true
o.relativenumber = true
o.clipboard = 'unnamedplus'
o.foldenable = true
o.foldlevel = 99
o.foldlevelstart = 99
vim.opt.diffopt:append("linematch:50")
vim.opt.signcolumn = "yes"
vim.opt.updatetime = 300

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
	fn.system({
		"git",
		"clone",
		"--filter=blob:none",
		"--single-branch",
		"https://github.com/folke/lazy.nvim.git",
		lazypath,
	})
end
vim.opt.runtimepath:prepend(lazypath)
require("lazy").setup({
	"pteroctopus/faster.nvim",
	{ "nvim-lua/plenary.nvim", "nvim-lua/popup.nvim", event = "VeryLazy" },
	{
		"echasnovski/mini.basics",
		event = "VeryLazy",
		version = false,
		dependencies = {
			"echasnovski/mini.cursorword",
			"echasnovski/mini.move",
			"echasnovski/mini.align",
		},
		config = function()
			require("mini.basics").setup()
			require("mini.cursorword").setup()
			require("mini.move").setup()
			require("mini.align").setup()
		end
	},
	{ "tpope/vim-fugitive",    "tpope/vim-rhubarb",   event = "VeryLazy" },
	{ "terryma/vim-expand-region", event = "VeryLazy" },
	{
		"smoka7/hop.nvim",
		version = "*",
		opts = {},
		cmd = { "HopWord", "HopLine", "HopPattern" },
		config = true,
	},
	{ "pechorin/any-jump.vim",      cmd = { "AnyJump", "AnyJumpVisual", "AnyJumpBack" } },
	{
		"nacro90/numb.nvim",
		event = "VeryLazy",
		config = true,
	},
	{ "machakann/vim-sandwich",  event = "VeryLazy" },
	{
		"folke/which-key.nvim",
		event = "VeryLazy",
		config = true
	},
	{ "ThePrimeagen/vim-be-good",       cmd = "VimBeGood" },
	{ "tpope/vim-repeat",      event = "VeryLazy" },
}, {
	root = fn.stdpath("data") .. "/lazy",
	rocks = {
		enabled = false,
		hererocks = false,
	},
})

o.clipboard = 'unnamedplus'
o.foldlevel = 99
o.foldlevelstart = 99
g.syntax = false
o.number = false
vim.opt.diffopt:append("linematch:50")

--mappings
local function map(mode, lhs, rhs)
	local options = { noremap = true }
	remap(mode, lhs, rhs, options)
end

map("n", ";f", "<C-f>")
map("n", ";b", "<C-b>")
remap("", "<D-v>", "+p<CR>", { noremap = true, silent = true })
remap("!", "<D-v>", "<C-R>+", { noremap = true, silent = true })
remap("t", "<D-v>", "<C-R>+", { noremap = true, silent = true })
remap("v", "<D-v>", "<C-R>+", { noremap = true, silent = true })
map("n", "j", "gj") --move by visual line not actual line
map("n", "k", "gk")

map("n", "gw", "<cmd>HopWord<CR>") --easymotion/hop
map("n", "gl", "<cmd>HopLine<CR>")
map("n", "g/", "<cmd>HopPattern<CR>")
